/*************************************************************************
	> File Name: acquisitor.h
	> Author: xuwenlong
	> Mail: myxuan475@126.com 
	> Created Time: 2018年02月02日 星期五 14时22分48秒
 ************************************************************************/
#ifndef __COLLECTOR_H__
#define __COLLECTOR_H__

#include <stdio.h>
#include "acquisitor.h"

class Collector:public Acquisitor
{
public:
    Collector(const deviceinfo_t& devinfo);
    virtual ~Collector();

    //采集数据
    void Run(tConnection connector,
            const time_t &acqtime,
             vector<AcqItem> &listAcquire);

    U16 acquireData(
            tConnection connector,
            vector<AcqItem> &listAcquire,
            U8 flag);

    BOOL OnReceiveJson(S32 index,
            DAS_RESULT result,
            const string &method,
            const Json::Value &json);

    virtual S32 commitData(S32 index);
    virtual void clearData();

private:
    bool hasItemId(S32 id);
    void resetCommit(S32 si);
    bool fetchCommitData(S32 si,Json::Value &params);
    void handleJsonResult(BOOL ret, S32 si);
private:
    Lock                    m_iDataLock;
    FixList<AcqData,5000>   m_fixlistData;
    time_t           m_last;
    U32  m_uCommits[MAX_TASK_DIVID]; //当前提交的位置
    U8   m_uCommitId;

};

#endif //__ACQUISITOR_H__

